package routes

import (
	"goweb2/internal/handler"
	"goweb2/internal/middleware"

	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/swagger"
)

// @title Fiber Advanced Demo API
// @version 1.0
// @description This is a sample API
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.email fiber@example.com
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:3000
// @BasePath /
// @schemes http
func SetupRoutes(app *fiber.App, jwtSecret string) {
	// Swagger
	app.Get("/swagger/*", swagger.HandlerDefault)

	// Public routes
	public := app.Group("/api")
	public.Post("/register", handler.Register)
	public.Post("/login", func(c *fiber.Ctx) error {
		return handler.Login(c, jwtSecret)
	})

	// Protected routes
	protected := app.Group("/api", middleware.JWTAuth(jwtSecret))
	protected.Get("/users", handler.GetUsers)
}
